package com.qf.flash.ui.business.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.qf.flash.R;
import com.qf.flash.http.response.GameDetailResponse;
import com.qf.flash.utils.ImageLoader;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;
import com.qf.flashlib.util.ViewUtil;

import butterknife.BindView;

/**
 * 创建日期：2020/3/15 on 15:21
 * 描述:
 * 作者:戴旭东
 */
public class MoneyRecodeItem extends BaseRViewItem<GameDetailResponse.UsersBean> {
    @BindView(R.id.iv_head)
    ImageView ivHead;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_level)
    TextView tvLevel;
    @BindView(R.id.tv_cuikuan)
    TextView tvCuikuan;
    @BindView(R.id.tv_result)
    TextView tvResult;
    private Context context;

    public MoneyRecodeItem(Context context) {
        this.context = context;
    }

    @Override
    public int getItemLayout() {
        return R.layout.item_money_recode;
    }

    @Override
    public void convert(RViewHolder holder, GameDetailResponse.UsersBean entity, int position, int itemSize) {
        TextView tvResult = holder.getView(R.id.tv_result);
        TextView tvCK = holder.getView(R.id.tv_cuikuan);
        TextView tvName = holder.getView(R.id.tv_name);
        ImageView ivhead = holder.getView(R.id.iv_head);
        if (entity.getIsRestMoney() == 1) {
            tvResult.setVisibility(View.VISIBLE);
            tvCK.setVisibility(View.GONE);
        } else {
            tvResult.setVisibility(View.GONE);
            tvCK.setVisibility(View.VISIBLE);
        }
        holder.setText(R.id.tv_name, entity.getName())
                .setText(R.id.tv_level, "LV." + entity.getLevel());
        holder.setOnClickListener(R.id.tv_cuikuan);
        tvResult.setText(context.getString(R.string.weikuan, entity.getRestMoney()));
        ImageLoader.loadCircleHead(context, entity.getPhoto(), ivhead);
        if ("2".equals(entity.getSex()))
            ViewUtil.setRightIcon(tvName, R.mipmap.icon_woman, 10);
        else {
            ViewUtil.setRightIcon(tvName, R.mipmap.icon_man, 10);
        }

    }
}
